from apps.models import BaseModel
from ext import db


class User(BaseModel):
    __tablename__ = 'users'

    # 邮箱
    email = db.Column(db.String(200), nullable=False, unique=True)
    # 密码
    password = db.Column(db.String(200), nullable=False)
    # 昵称
    user_name = db.Column(db.String(200), nullable=False, unique=True)
    # 头像
    portrait = db.Column(db.String(200))

    # 是否是黑名单
    blacklist = db.Column(db.Boolean, default=False)
    # 是否删除
    is_del = db.Column(db.Boolean, default=False)
    # 删除时间
    del_time = db.Column(db.DateTime())


# 用户的书架
class UserBookshelf(BaseModel):
    __tablename__ = 'user_bookshelves'
    # 用户ID
    user_id = db.Column(db.Integer, nullable=False)
    # 书ID
    book_id = db.Column(db.Integer, nullable=False)
    # 是否删除
    is_del = db.Column(db.Boolean, default=False)
    # 删除时间
    del_time = db.Column(db.DateTime())


